﻿using BS.Infra;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BS.Write.Api.Controllers
{
    /// <summary>
    /// 溯源控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TranceShuoYuanController : ControllerBase
    {
        private readonly IMediator _mediator;

        public TranceShuoYuanController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 新增硕源信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> AddTrance(InsertTranceShuoYuanCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 删除硕源信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<ApiResult> DelTrance([FromQuery]DelTranceShuoYuanCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 修改硕源信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult> UpdateTrance(UpdateTranceShuoYuanCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
